<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li><input type="text" placeholder="请输入名字" name="name"></li>
        <li><input type="text" placeholder="请输入技能" name="skills"></li>
        <li><button type="submit">提交</button></li>
    </ul>

    <!-- js -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script>
        $(function () {
            $('button').click(function () {
                if ($('[name="name"]').val() && $('[name="skills"]').val()) {
                    console.log($('[name="name"]').val())
                    $.ajax({
                        type: "post",
                        url: "/api/v1/pets",
                        data: {
                            name: $('[name="name"]').val(),
                            skills: $('[name="skills"]').val(),
                        },
                        success: function (response) {
                            window.location.href = "./index.html";
                        }
                    });
                } else {
                    alert(' 请输入内容');
                }
            });
        });
    </script>
</body>

</html>